package org.linlinjava.litemall.wx.controller;

import io.swagger.annotations.*;
import lombok.RequiredArgsConstructor;
import org.linlinjava.litemall.core.util.ResponseUtil;
import org.linlinjava.litemall.wx.annotation.LogAnno;
import org.linlinjava.litemall.wx.annotation.LoginUser;
import org.linlinjava.litemall.wx.service.WxLumiereCouponStrategyService;
import org.linlinjava.litemall.wx.vo.WxMyCouponsVO;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;

@Api(tags = "优惠券策略API")
@RestController
@RequiredArgsConstructor
@RequestMapping("/wx/strategy")
public class WxLumiereCouponStrategyController extends ResponseUtil {

    private final WxLumiereCouponStrategyService wxLumiereCouponStrategyService;

    @ApiOperation("优惠券策略-「我的｜我的优惠券中的列表」")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "page",value = "page"),
            @ApiImplicitParam(name = "limit",value = "limit"),
            @ApiImplicitParam(name = "type",value = "分类(0未使用、1已使用、2已过期)")
    })
    @ApiResponse(code = 0,message = "success",response = WxMyCouponsVO.class)
    @LogAnno
    @GetMapping("/coupons")
    public Response coupons(@ApiIgnore @LoginUser Integer userId,
                            @RequestParam("page")Integer page,
                            @RequestParam("limit")Integer limit,
                            @RequestParam("type")Integer type){
        return wxLumiereCouponStrategyService.coupons(userId,page,limit,type);
    }

    @ApiOperation("优惠券策略-「领取优惠券｜app首页点击领取优惠券的接口」")
    @ApiImplicitParam(name = "strategyId",value = "策略ID")
    @LogAnno
    @GetMapping("/pull")
    public Response pullCoupon(@LoginUser Integer userId, @RequestParam("strategyId")Long strategyId){
        return wxLumiereCouponStrategyService.pullCoupon(userId,strategyId);
    }




}
